const mongoose = require("mongoose");
const { theaters } = require("./data/theaters.js");
const Schema = mongoose.Schema;
// 创建数据结构
const theatersSchema = new Schema({
  id: String, // mongodb 自动生成的 id
  name: String, // 放映厅名字
  status: Boolean, // 放映厅是否营业（可选）
  cinemasId: String, // 放映厅从属的影院 id
  cinema:String,//所属影院
});
const theatersModel = mongoose.model("theaters", theatersSchema, "theaters");
mongoose.connect(
  "mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/maiwenjie",
  {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    auth: { authSource: "admin" },
  },
  async () => {
    // 当连接成功后触发
    // 创建学生数据 一个（对象）或多个（数组）
    await theatersModel.create(theaters);
  }
);
